package com.cc.demo.component.retry.local;

import com.aizuda.snailjob.client.core.annotation.Retryable;
import com.aizuda.snailjob.client.core.retryer.RetryType;
import com.cc.demo.component.retry.SceneConstant;
import org.springframework.stereotype.Service;

@Service
public class LocalRetryServiceImpl implements LocalRetryService {

    private static int times = 0;
    @Override
    @Retryable(scene = SceneConstant.LOCAL_RETRY, retryStrategy = RetryType.ONLY_LOCAL)
    public String localRetry(String params) {
        if (times < 3) {
            times++;
            System.out.println("local retry 方法开始执行");
            throw new RuntimeException("local retry 方法执行异常");
        }
        times = 0;
        return "Success";
    }
}
